package com.zhny.iot.transparent.pump.plugin;

import com.zhny.aiot.plugin.ICenterFacilities;
import com.zhny.aiot.plugin.IDevice;
import com.zhny.aiot.plugin.modbus.ModemServer;
import com.zhny.aiot.plugin.modbus.device.ModemConfig;
import com.zhny.aiot.plugin.modbus.device.ModemDeviceFactory;
import com.zhny.aiot.plugin.modbus.handler.model.ModemRequestMessage;
import com.zhny.aiot.plugin.model.CommandEntry;
import com.zhny.aiot.plugin.model.DeviceEntity;
import com.zhny.aiot.plugin.model.FactoryType;
import com.zhny.aiot.plugin.model.StoreEntity;
import com.zhny.iot.transparent.pump.plugin.model.ZhnyPumpHouseControlStoreEntity;
import org.pf4j.Extension;
import org.pf4j.Plugin;
import org.pf4j.PluginWrapper;

import java.util.ArrayList;
import java.util.List;

/**
 * 首部控制柜2通道
 * @Author pengshuai
 * @Date 2023/11/24
 */
public class ZhnyPumpHouseControlPlugin extends Plugin {

    public ZhnyPumpHouseControlPlugin(PluginWrapper wrapper) {
        super(wrapper);
    }

    @Extension
    public static class ZhnyPumpHouseControlTransparentFactory extends ModemDeviceFactory<ZhnyPumpHouseControlStoreEntity> {

        @Override
        public List<CommandEntry> supportCommandClasses(){
            List<CommandEntry> commandList = new ArrayList<>();
            commandList.add(CommandEntry.valueOf("open1","打开通道1","无参数",""));
            commandList.add(CommandEntry.valueOf("close1","关闭通道1","无参数",""));
            commandList.add(CommandEntry.valueOf("query","检测状态","无参数",""));
            commandList.add(CommandEntry.valueOf("open2","打开通道2","无参数",""));
            commandList.add(CommandEntry.valueOf("close2","关闭通道2","无参数",""));
            return commandList;
        }

        @Override
        public IDevice createDevice(ICenterFacilities iCenterFacilities, DeviceEntity deviceEntity) {
            return new ZhnyPumpHouseControlDevice(ModemServer.getInstance().getEngine(),this,iCenterFacilities,deviceEntity);
        }

        @Override
        public Class<? extends StoreEntity> storeClass() {
            return ZhnyPumpHouseControlStoreEntity.class;
        }

        @Override
        public String getId() {
            return "zhny-head-control-box2Access-transparent-plugin";
        }

        @Override
        public String getName() {
            return "首部控制箱（2通道透传）";
        }

        @Override
        public FactoryType getType() {
            return FactoryType.PumpController;
        }

        @Override
        public ModemRequestMessage getRequestMessage(ModemConfig modemConfig) {
            return null;
        }
    }

}
